$(document).ready(function() {

$("#platform > dd").click(function() {
	var platform = $(this).attr('platform');
	if(typeof platform == 'undefined') top.location.href = "/";
	else {
		$('#leftFrame', parent.document.body).attr('src', 'tree/?platform='+platform);
	}
	$(this).addClass('on').siblings().removeClass('on');
});

$('[name="logout"]').click(function() {
	top.location.href = "/auth/logout";
});

var timer = {
	_start : $('[name="timer"]').attr('default')*1000,
	run : function() {
		timer._start = timer._start+1000;
		var Days = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
		var dt = new Date(timer._start-1000);
		
		var y = dt.getFullYear();
		
		var m = dt.getMonth()+1;
		m = m < 10? '0'+m: m;
		
		var d = dt.getDate();
		d = d < 10? '0'+d: d;
		
		var h = dt.getHours();
		h = h < 10? '0'+h: h;
		
		var s = dt.getMinutes();
		s = s < 10? '0'+s: s;
		
		var i = dt.getSeconds();
		i = i < 10? '0'+i: i;
		
		var w = Days[dt.getDay()];
		
		$($('[name="timer"]')).text(y+'年'+m+'月'+d+'日 '+w+' '+h+':'+s+':'+i);
	}
};

setInterval(timer.run, 1000);
});